const ROUTES = [{
  icon: 'admin',
  key: 'admin',
  title: '管理员',
  childs: [{
    title: '管理员名单',
    route: 'adminList',
  }],
}, {
  icon: 'user',
  key: 'user',
  title: '用户管理',
  childs: [{
    title: '用户列表',
    route: 'userList',
  }],
}, {
  icon: 'wap',
  key: 'wap',
  title: '手机端页面管理',
  childs: [{
    title: '底部导航',
    route: 'footerNav',
  }, {
    title: '贷款产品',
    route: 'loanProduct',
  }, {
    title: '我的',
    route: 'profile',
  }],
  group: [{
    title: '首页',
    childs: [{
      title: 'banner',
      route: 'indexBanner',
    }, {
      title: '滚动广告',
      route: 'scrollAd',
    }, {
      title: '首页导航',
      route: 'indexNav',
    }],
  }, {
    title: '信用卡',
    childs: [{
      title: 'banner',
      route: 'creditBanner',
    }, {
      title: '热门申请',
      route: 'creditHot',
    }, {
      title: '小编推荐',
      route: 'creditRecommend',
    }],
  }],
}, {
  icon: 'material',
  key: 'material',
  title: '素材管理',
  childs: [{
    title: '图片库',
    route: 'gallery',
  }, {
    title: '图文消息',
    route: 'graphicMsg',
  }, {
    title: '文章列表',
    route: 'articlesList',
  }, {
    title: '官网管理',
    route: 'officialSite',
  }],
}, {
  icon: 'stat',
  key: 'stat',
  title: '网站统计',
  childs: [{
    title: '网站统计',
    route: 'overall',
  }],
  // childs: [{
  //   title: '网站概况',
  //   route: 'overall',
  // }, {
  //   title: '栏目统计',
  //   route: 'column',
  // }, {
  //   title: '贷款产品统计',
  //   route: 'loanProduct',
  // }, {
  //   title: '信用卡产品统计',
  //   route: 'creditCard',
  // }, {
  //   title: '文章统计',
  //   route: 'post',
  // }],
}]

function createRoutesMap(routesConfig) {
  const map = {}
  const loop = (cfg) => {
    for (let i = 0, l = cfg.length; i < l; i += 1) {
      const item = cfg[i]
      if (item.route && typeof (item.route) === 'string') {
        map[item.route] = item.title
      }

      if (item.group && item.group.length) {
        loop(item.group)
      }

      if (item.childs && item.childs.length) {
        loop(item.childs)
      }
    }
  }
  loop(routesConfig)
  return map
}

const routesMap = createRoutesMap(ROUTES)

export {
  routesMap,
}
export default ROUTES
